"""用于封装接口"""


from cgitb import reset
from http.client import responses
from utils.random_data_maker import random_data_maker as rd
import pytest
from utils.logger import log
from API_cases.http_client import HttpClient
from config.env import LLM

#健康
def healthy(method):
    response = method.get(endpoint='/sanji/v1/monitoring/health/')
    log.debug("\n"+str(response.json()))
    return response



#登录
def login(method,json = None, data = None):
    response = method.post(endpoint="/sanji/v1/admin/tb_users/login/", json=json,data = data)
    if response.status_code == 200:
        LLM.token = response.json()['access_token']
        LLM.refresh_token = response.json()['refresh_token']
    log.debug("\n"+str(response.json()))
    return response


#刷新token
def refresh_token(method):

    json = {
        "refresh_token": LLM.refresh_token,
    }

    response = method.post(endpoint="/sanji/v1/admin/tb_users/refresh_token/", json=json)
    log.debug("\n"+str(response.json()))
    return response


#查询用户列表
def tb_users_list(method, params = None, headers = None,number = None):

    response = method.get(endpoint = "/sanji/v1/admin/tb_users/",headers =headers,params = params )
    log.debug("\n"+str(response.json()))

    return response


#创建用户
def tb_user_create(method, json = None, data = None,params = None, headers = None):

    response = method.post(endpoint = "/sanji/v1/admin/tb_users/",headers =headers,params = params ,json = json ,data = data)
    log.debug("\n"+str(response.json()))

    return response


#删除用户
def tb_user_delete(method, json = None, data = None,params = None, headers = None):

    response = method.delete(endpoint = "/sanji/v1/admin/tb_users/",headers =headers,params = params ,json = json ,data = data)
    log.debug("\n"+str(response.json()))
    return response
